#!/usr/bin/env ruby

class Object
  # new behavior for built-in methods
  alias :old_kind_of? :kind_of?
  alias :old_is_a? :is_a?
  
  def kind_of?(*classes)
    unless classes.size > 0
      raise ArgumentError, 'wrong number of args (0 for 1 or more)', caller
    end
    
    result = classes.detect { |cls| old_kind_of?(cls) }
    if result
      return true
    else
      return false
    end
  end
  
  alias :is_a? :kind_of?
end

########################################

=begin
#doctest Demo Object.is_a? and Object.kind_of?
>> s = 'foo'
=> "foo"
>> puts s.is_a?(String)
=> true
>> puts s.is_a?(Hash, String)
=> true
>> puts s.is_a?(Fixnum, Array)
=> false
>> puts s.kind_of?(String)
=> true
>> puts s.kind_of?(Hash, String)
=> true
>> puts s.kind_of?(Fixnum, Array)
=> false
=end
